using System;
using System.Collections.Generic;
using System.Text;
using Utility;
using Entites;
using DAL;
namespace BUS
{
   public class TinhTrangGiaoHangBUS
    {
         public static void Insert(TinhTrangGiaoHang ttgh)
        {
            TinhTrangGiaoHangDAL ttghDAL = new TinhTrangGiaoHangDAL();
           ttghDAL.Insert(ttgh);
        }
        public static void Update(TinhTrangGiaoHang ttgh)
        {
            TinhTrangGiaoHangDAL ttghDAL = new TinhTrangGiaoHangDAL();
            ttghDAL.Update(ttgh);
        }
        public static void Delete(int iD)
        {
            TinhTrangGiaoHangDAL ttghDAL = new TinhTrangGiaoHangDAL();
            ttghDAL.Delete(iD);
        }
        public static tbTinhTrangGiaoHangCollection Get(string where,
            int pageindex,
            int pagesize,
            string orderby,
            string orderdirection,
            out int total)
        {
            TinhTrangGiaoHangDAL ttghDAL = new TinhTrangGiaoHangDAL();
            return ttghDAL.Get(where, pageindex, pagesize, orderby, orderdirection, out total);
        }
        public static tbTinhTrangGiaoHangCollection GetAll()
        {
            int total = 0;
            Criteria cri = new Criteria();
            TinhTrangGiaoHangDAL ttghDAL = new TinhTrangGiaoHangDAL();
            return ttghDAL.Get(cri.Criter, 0, 0, tbTinhTrangGiaoHangColumns.MaTTGH.ToString(), OrderDirection.ASC.ToString(), out total);
        }
       public static TinhTrangGiaoHang GetByID(int iD)
       {
           int total = 0;
           Criteria cri = new Criteria();
           cri.add(Condition.AND, tbTinhTrangGiaoHangColumns.MaTTGH.ToString(), Condition.EQUAL, iD);
           TinhTrangGiaoHangDAL ttghDAL = new TinhTrangGiaoHangDAL();
           tbTinhTrangGiaoHangCollection tinhtranggiaohangcollection = ttghDAL.Get(cri.Criter,
                 0, 0, tbTinhTrangGiaoHangColumns.MaTTGH.ToString(), OrderDirection.ASC.ToString(), out total);
           if (tinhtranggiaohangcollection.Count > 0)
               return tinhtranggiaohangcollection[0];
           return null;
       }
      
        public static tbTinhTrangGiaoHangCollection GetLimited(int number)
        {
            int total = 0;
            Criteria cri = new Criteria();
            TinhTrangGiaoHangDAL ttghDAL = new TinhTrangGiaoHangDAL();
            return ttghDAL.Get(cri.Criter, 1, number,
             tbTinhTrangGiaoHangColumns.MaTTGH.ToString(), OrderDirection.DESC.ToString(), out total);
        }
        public static tbTinhTrangGiaoHangCollection GetPromotion(int number)
        {
            int total = 0;
            Criteria cri = new Criteria();
            TinhTrangGiaoHangDAL ttghDAL = new TinhTrangGiaoHangDAL();
            return ttghDAL.Get(cri.Criter, 1, number,
               tbTinhTrangGiaoHangColumns.MaTTGH.ToString(), OrderDirection.DESC.ToString(), out total);
        }
    }
    
    }

